package com.demo.service.impl;

import com.demo.dao.Course;
import com.demo.mapper.CourseMapper;
import com.demo.service.CourseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CourseServiceImpl implements CourseService {

    @Autowired
    CourseMapper courseMapper;

    @Override
    public List<Course> findAllCourse() {
        return courseMapper.findAllCourse();
    }

    @Override
    public String findNameById(int cid) {
        return courseMapper.findNameById(cid);
    }

    @Override
    public List<String> findAllCourseByTerm(String term) {
        return courseMapper.findAllCourseByTerm(term);
    }

    @Override
    public List<Course> findCourseByTerm(String term) {
        return courseMapper.findCourseByTerm(term);
    }

    @Override
    public List<Integer> transIdByName(List<String> names) {
        List<Integer> result = null;
        for (String i:names
             ) {
            result.add(courseMapper.getCidByName(i));
        }
        return result;
    }

    @Override
    public Course findCourseByCid(int cid) {
        return courseMapper.findCourseByCid(cid);
    }

    @Override
    public Integer getCidByName(String cname) {
        return courseMapper.getCidByName(cname);
    }


}
